package gui;

import javax.swing.JPanel;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import main.Controller;

import javax.swing.JTextArea;
import javax.swing.JComboBox;

/**
 * 
 * @author Christian
 * @since 0.15d
 * 
 * 
 */
public class EditZauberVariante extends JPanel {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * 
	 */
	private JLabel jLabel = null;
	
	/**
	 * 
	 */
	private JPanel jPanel = null;
	
	/**
	 * 
	 */
	private JButton jZurueckButton = null;
	
	/**
	 * 
	 */
	private JButton jSpeichernButton = null;
	
	/**
	 * 
	 */
	private EditZauberVariantenController addController = new EditZauberVariantenController(this);
	
	/**
	 * 
	 */
	private JLabel jLabel1 = null;
	
	/**
	 * 
	 */
	private JTextArea jKostenTextArea = null;
	
	/**
	 * 
	 */
	private JTextArea jWirkungsDauerTextArea = null;
	
	/**
	 * 
	 */
	private JTextArea jZauberDauerTextArea = null;
	
	/**
	 * 
	 */
	private JTextArea jAnmerkungTextArea = null;
	
	/**
	 * 
	 */
	private JLabel jLabel2 = null;
	
	/**
	 * 
	 */
	private JLabel jLabel3 = null;
	
	/**
	 * 
	 */
	private JLabel jLabel4 = null;
	
	/**
	 * 
	 */
	private JLabel jLabel5 = null;
	
	/**
	 * 
	 */
	private JLabel jLabel6 = null;
	
	/**
	 * 
	 */
	private JLabel jLabel7 = null;
	
	/**
	 * 
	 */
	private JTextArea jKommentarTextArea = null;
	
	/**
	 * 
	 */
	private JLabel jLabel8 = null;
	
	/**
	 * 
	 */
	private JComboBox jVariantenAuswahlComboBox = null;
	
	/**
	 * 
	 */
	private JButton jDelButton = null;
	
	/**
	 * 
	 */
	private EditZauberVariantenController editController = new EditZauberVariantenController(this);
	
	/**
	 * 
	 */
	private JLabel jInfoLabel = null;
	
	/**
	 * 
	 */
	private JComboBox jZauberNameComboBox = null;
	
	/**
	 * 
	 */
	private JComboBox jRepComboBox = null;
	
	/**
	 * 
	 */
	private JTextArea jReichweiteTextArea = null;
	
	/**
	 * 
	 */
	private JLabel jLabel9 = null;
	
	/**
	 * This method initializes
	 * 
	 */
	public EditZauberVariante() {

		super();
		initialize();
	}
	
	/**
	 * This method initializes this
	 * 
	 */
	private void initialize() {

		GridBagConstraints gridBagConstraints62 = new GridBagConstraints();
		gridBagConstraints62.insets = new Insets(0, 0, 5, 5);
		gridBagConstraints62.gridx = 0;
		gridBagConstraints62.gridy = 8;
		jLabel9 = new JLabel();
		jLabel9.setText("Reichweite:");
		GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
		gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
		gridBagConstraints5.gridy = 8;
		gridBagConstraints5.weightx = 1.0;
		gridBagConstraints5.insets = new Insets(5, 10, 5, 0);
		gridBagConstraints5.weighty = 1.0;
		gridBagConstraints5.gridwidth = 2;
		gridBagConstraints5.gridx = 1;
		GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
		gridBagConstraints4.fill = GridBagConstraints.VERTICAL;
		gridBagConstraints4.gridy = 3;
		gridBagConstraints4.weightx = 1.0;
		gridBagConstraints4.insets = new Insets(5, 5, 5, 5);
		gridBagConstraints4.gridx = 1;
		GridBagConstraints gridBagConstraints32 = new GridBagConstraints();
		gridBagConstraints32.fill = GridBagConstraints.VERTICAL;
		gridBagConstraints32.gridy = 2;
		gridBagConstraints32.weightx = 1.0;
		gridBagConstraints32.insets = new Insets(5, 5, 5, 5);
		gridBagConstraints32.gridx = 1;
		GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
		gridBagConstraints7.insets = new Insets(0, 0, 5, 5);
		gridBagConstraints7.gridx = 1;
		gridBagConstraints7.gridy = 1;
		jInfoLabel = new JLabel();
		jInfoLabel.setText(" ");
		GridBagConstraints gridBagConstraints61 = new GridBagConstraints();
		gridBagConstraints61.gridx = 2;
		gridBagConstraints61.gridy = 4;
		gridBagConstraints61.insets = new Insets(5, 5, 5, 0);
		GridBagConstraints gridBagConstraints51 = new GridBagConstraints();
		gridBagConstraints51.fill = GridBagConstraints.VERTICAL;
		gridBagConstraints51.gridy = 4;
		gridBagConstraints51.insets = new Insets(5, 5, 5, 5);
		gridBagConstraints51.weightx = 1.0;
		gridBagConstraints51.gridx = 1;
		GridBagConstraints gridBagConstraints17 = new GridBagConstraints();
		gridBagConstraints17.fill = GridBagConstraints.VERTICAL;
		gridBagConstraints17.gridy = 2;
		gridBagConstraints17.weightx = 1.0;
		gridBagConstraints17.gridx = 1;
		GridBagConstraints gridBagConstraints20 = new GridBagConstraints();
		gridBagConstraints20.insets = new Insets(0, 0, 5, 5);
		gridBagConstraints20.gridx = 0;
		gridBagConstraints20.gridy = 10;
		jLabel8 = new JLabel();
		jLabel8.setText("Kommentar:");
		GridBagConstraints gridBagConstraints19 = new GridBagConstraints();
		gridBagConstraints19.fill = GridBagConstraints.HORIZONTAL;
		gridBagConstraints19.gridy = 10;
		gridBagConstraints19.weightx = 1.0;
		gridBagConstraints19.weighty = 1.0;
		gridBagConstraints19.insets = new Insets(5, 10, 5, 0);
		gridBagConstraints19.gridwidth = 2;
		gridBagConstraints19.gridx = 1;
		GridBagConstraints gridBagConstraints16 = new GridBagConstraints();
		gridBagConstraints16.insets = new Insets(0, 0, 5, 5);
		gridBagConstraints16.gridx = 0;
		gridBagConstraints16.gridy = 9;
		jLabel7 = new JLabel();
		jLabel7.setText("Anmerkung:");
		GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
		gridBagConstraints15.insets = new Insets(0, 0, 5, 5);
		gridBagConstraints15.gridx = 0;
		gridBagConstraints15.gridy = 7;
		jLabel6 = new JLabel();
		jLabel6.setText("Wirkungsdauer:");
		GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
		gridBagConstraints14.insets = new Insets(0, 0, 5, 5);
		gridBagConstraints14.gridx = 0;
		gridBagConstraints14.gridy = 6;
		jLabel5 = new JLabel();
		jLabel5.setText("Zauberdauer:");
		GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
		gridBagConstraints13.insets = new Insets(0, 0, 5, 5);
		gridBagConstraints13.gridx = 0;
		gridBagConstraints13.gridy = 5;
		jLabel4 = new JLabel();
		jLabel4.setText("Kosten:");
		GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
		gridBagConstraints12.insets = new Insets(0, 0, 5, 5);
		gridBagConstraints12.gridx = 0;
		gridBagConstraints12.gridy = 3;
		jLabel3 = new JLabel();
		jLabel3.setText("Repräsentation:");
		GridBagConstraints gridBagConstraints111 = new GridBagConstraints();
		gridBagConstraints111.insets = new Insets(0, 0, 5, 5);
		gridBagConstraints111.gridx = 0;
		gridBagConstraints111.gridy = 2;
		jLabel2 = new JLabel();
		jLabel2.setText("Zaubername:");
		GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
		gridBagConstraints10.fill = GridBagConstraints.HORIZONTAL;
		gridBagConstraints10.gridy = 9;
		gridBagConstraints10.weightx = 1.0;
		gridBagConstraints10.insets = new Insets(5, 10, 5, 0);
		gridBagConstraints10.weighty = 1.0;
		gridBagConstraints10.gridwidth = 2;
		gridBagConstraints10.gridx = 1;
		GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
		gridBagConstraints9.fill = GridBagConstraints.HORIZONTAL;
		gridBagConstraints9.gridy = 6;
		gridBagConstraints9.weightx = 1.0;
		gridBagConstraints9.weighty = 1.0;
		gridBagConstraints9.insets = new Insets(5, 10, 5, 0);
		gridBagConstraints9.gridwidth = 2;
		gridBagConstraints9.gridx = 1;
		GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
		gridBagConstraints8.fill = GridBagConstraints.HORIZONTAL;
		gridBagConstraints8.gridy = 7;
		gridBagConstraints8.weightx = 1.0;
		gridBagConstraints8.insets = new Insets(5, 10, 5, 0);
		gridBagConstraints8.weighty = 1.0;
		gridBagConstraints8.gridwidth = 2;
		gridBagConstraints8.gridx = 1;
		GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
		gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL;
		gridBagConstraints6.gridy = 5;
		gridBagConstraints6.weightx = 1.0;
		gridBagConstraints6.weighty = 1.0;
		gridBagConstraints6.insets = new Insets(5, 10, 5, 0);
		gridBagConstraints6.gridwidth = 2;
		gridBagConstraints6.gridx = 1;
		GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
		gridBagConstraints3.insets = new Insets(0, 0, 5, 5);
		gridBagConstraints3.gridx = 0;
		gridBagConstraints3.gridy = 4;
		jLabel1 = new JLabel();
		jLabel1.setText("VariantenName:");
		GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
		gridBagConstraints11.insets = new Insets(0, 0, 0, 5);
		gridBagConstraints11.gridx = 1;
		gridBagConstraints11.gridy = 11;
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridy = 0;
		gridBagConstraints.gridx = 1;
		gridBagConstraints.insets = new Insets(10, 5, 5, 5);
		jLabel = new JLabel();
		jLabel.setText("Zaubervariante verändern");
		this.setLayout(new GridBagLayout());
		this.setSize(new Dimension(589, 451));
		this.add(jLabel, gridBagConstraints);
		this.add(getJPanel(), gridBagConstraints11);
		this.add(jLabel1, gridBagConstraints3);
		this.add(getJKostenTextArea(), gridBagConstraints6);
		this.add(getJWirkungsDauerTextArea(), gridBagConstraints8);
		this.add(getJZauberDauerTextArea(), gridBagConstraints9);
		this.add(getJAnmerkungTextArea(), gridBagConstraints10);
		this.add(jLabel2, gridBagConstraints111);
		this.add(jLabel3, gridBagConstraints12);
		this.add(jLabel4, gridBagConstraints13);
		this.add(jLabel5, gridBagConstraints14);
		this.add(jLabel6, gridBagConstraints15);
		this.add(jLabel7, gridBagConstraints16);
		this.add(getJKommentarTextArea(), gridBagConstraints19);
		this.add(jLabel8, gridBagConstraints20);
		this.add(getJVariantenAuswahlComboBox(), gridBagConstraints51);
		this.add(getJDelButton(), gridBagConstraints61);
		this.add(jInfoLabel, gridBagConstraints7);
		this.add(getJZauberNameComboBox(), gridBagConstraints32);
		this.add(getJRepComboBox(), gridBagConstraints4);
		this.add(getJReichweiteTextArea(), gridBagConstraints5);
		this.add(jLabel9, gridBagConstraints62);
	}
	
	/**
	 * This method initializes jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel() {

		if (jPanel == null) {
			jPanel = new JPanel();
			jPanel.setLayout(new GridBagLayout());
			GridBagConstraints gbc_jZurueckButton = new GridBagConstraints();
			gbc_jZurueckButton.insets = new Insets(5, 5, 5, 5);
			gbc_jZurueckButton.gridx = 0;
			gbc_jZurueckButton.gridy = 0;
			jPanel.add(getJZurueckButton(), gbc_jZurueckButton);
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.gridx = 1;
			gridBagConstraints2.gridy = 0;
			gridBagConstraints2.insets = new Insets(5, 5, 5, 5);
			jPanel.add(getJSpeichernButton(), gridBagConstraints2);
		}
		return jPanel;
	}
	
	/**
	 * This method initializes jZurueckButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJZurueckButton() {

		if (jZurueckButton == null) {
			jZurueckButton = new JButton();
			jZurueckButton.setText("zurück");
			jZurueckButton.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {

					Controller.getGuiController().zeigeHauptfenster();
				}
			});
		}
		return jZurueckButton;
	}
	
	/**
	 * This method initializes jSpeichernButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJSpeichernButton() {

		if (jSpeichernButton == null) {
			jSpeichernButton = new JButton();
			jSpeichernButton.setText("speichern");
			jSpeichernButton.addActionListener(addController);
		}
		return jSpeichernButton;
	}
	
	/**
	 * This method initializes jKostenTextArea
	 * 
	 * @return javax.swing.JTextArea
	 */
	public JTextArea getJKostenTextArea() {

		if (jKostenTextArea == null) {
			jKostenTextArea = new JTextArea();
			jKostenTextArea.setLineWrap(true);
		}
		return jKostenTextArea;
	}
	
	/**
	 * This method initializes jWirkungsDauerTextArea
	 * 
	 * @return javax.swing.JTextArea
	 */
	public JTextArea getJWirkungsDauerTextArea() {

		if (jWirkungsDauerTextArea == null) {
			jWirkungsDauerTextArea = new JTextArea();
			jWirkungsDauerTextArea.setLineWrap(true);
		}
		return jWirkungsDauerTextArea;
	}
	
	/**
	 * This method initializes jZauberDauerTextArea
	 * 
	 * @return javax.swing.JTextArea
	 */
	public JTextArea getJZauberDauerTextArea() {

		if (jZauberDauerTextArea == null) {
			jZauberDauerTextArea = new JTextArea();
			jZauberDauerTextArea.setLineWrap(true);
		}
		return jZauberDauerTextArea;
	}
	
	/**
	 * This method initializes jAnmerkungTextArea
	 * 
	 * @return javax.swing.JTextArea
	 */
	public JTextArea getJAnmerkungTextArea() {

		if (jAnmerkungTextArea == null) {
			jAnmerkungTextArea = new JTextArea(2, 30);
			jAnmerkungTextArea.setLineWrap(true);
		}
		return jAnmerkungTextArea;
	}
	
	/**
	 * This method initializes jKommentarTextArea
	 * 
	 * @return javax.swing.JTextArea
	 */
	public JTextArea getJKommentarTextArea() {

		if (jKommentarTextArea == null) {
			jKommentarTextArea = new JTextArea(2, 30);
			jKommentarTextArea.setLineWrap(true);
		}
		return jKommentarTextArea;
	}
	
	/**
	 * This method initializes jVariantenAuswahlComboBox
	 * 
	 * @return javax.swing.JComboBox
	 */
	public JComboBox getJVariantenAuswahlComboBox() {

		if (jVariantenAuswahlComboBox == null) {
			jVariantenAuswahlComboBox = new JComboBox();
			jVariantenAuswahlComboBox.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {

					editController.update(true);
				}
			});
			jVariantenAuswahlComboBox.setEnabled(false);
			editController.fillComboBox();
		}
		return jVariantenAuswahlComboBox;
	}
	
	/**
	 * This method initializes jDelButton
	 * 
	 * @return javax.swing.JButton
	 */
	public JButton getJDelButton() {

		if (jDelButton == null) {
			jDelButton = new JButton();
			jDelButton.setText("-");
			jDelButton.addActionListener(editController);
		}
		return jDelButton;
	}
	
	/**
	 * @return the jInfoLabel
	 */
	public JLabel getJInfoLabel() {

		return jInfoLabel;
	}
	
	/**
	 * This method initializes jZauberNameComboBox
	 * 
	 * @return javax.swing.JComboBox
	 */
	public JComboBox getJZauberNameComboBox() {

		if (jZauberNameComboBox == null) {
			jZauberNameComboBox = new JComboBox();
			for (String rep : Controller.getDatenController().getAlleZauberNamen()) {
				jZauberNameComboBox.addItem(rep);
			}
			jZauberNameComboBox.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {

					editController.fillComboBox();
				}
			});
			if (jZauberNameComboBox.getItemCount() > 0) {
				jZauberNameComboBox.setSelectedIndex(0);
			}
			// jZauberNameComboBox.setSelectedIndex(0);
		}
		return jZauberNameComboBox;
	}
	
	/**
	 * This method initializes jRepComboBox
	 * 
	 * @return javax.swing.JComboBox
	 */
	public JComboBox getJRepComboBox() {

		if (jRepComboBox == null) {
			jRepComboBox = new JComboBox();
			for (String rep : Controller.getDatenController().getRepraesentationenList()) {
				jRepComboBox.addItem(rep);
			}
			jRepComboBox.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {

					editController.fillComboBox();
				}
			});
			if (jRepComboBox.getItemCount() > 0) {
				jRepComboBox.setSelectedIndex(0);
			}
		}
		return jRepComboBox;
	}
	
	/**
	 * This method initializes jReichweiteTextArea
	 * 
	 * @return javax.swing.JTextArea
	 */
	public JTextArea getJReichweiteTextArea() {

		if (jReichweiteTextArea == null) {
			jReichweiteTextArea = new JTextArea();
			jReichweiteTextArea.setLineWrap(true);
		}
		return jReichweiteTextArea;
	}
} // @jve:decl-index=0:visual-constraint="176,10"
